/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bitcar.platform.system.model.logic;

import com.bitcar.platform.system.model.User;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 *
 * @author shd
 */
public class UserValidator implements Validator {

    @Override
    public boolean supports(Class<?> type) {
        return User.class.isAssignableFrom(type);
    }

    @Override
    public void validate(Object o, Errors errors) {
        ValidationUtils.rejectIfEmpty(errors, "username", "UserName", "用户名不能为空");
        ValidationUtils.rejectIfEmpty(errors, "password", "Password", "密码不能为空");
        ValidationUtils.rejectIfEmpty(errors, "email", "Email", "邮箱不能为空");
    }
}
